fix(asr): 修复 Windows 本地长语音只识别前段#769
Open
Duyi-Wang wants to merge 1 commit into
Open
Conversation
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
摘要
修复 Windows 本地 ASR 在长语音场景下可能只识别前一段的问题。
主要原因是
foundry-local-whisper使用 Whisper 系模型,单次解码窗口约 30 秒;当录音超过这个窗口时,单次把整段 WAV 交给 Foundry SDK 可能只返回前段结果。这个 PR 将 Foundry Local Whisper 的 PCM 输入按 30 秒分片转写,再合并分片文本;同时把 Windows 本地 ASR 的转写超时从固定 30 秒改为按音频时长动态增长。未关联 issue。
修复 / 新增 / 改进
foundry-local-whisper录音结束后按 30 秒 PCM chunk 分片,逐段生成临时 WAV 并调用 Foundry SDK。buffer_duration_ms(),coordinator 可按实际录音长度计算 timeout。max(30s, ceil(audio_s) + 20s),避免长音频撞固定 30 秒超时。兼容
不包含:
对现有用户 / 本地环境 / 构建流程的影响:
foundry-local-whisper下会拆成多段本地识别,整体耗时会随音频长度增加,但可以覆盖完整录音。sherpa-onnx-local仅调整 timeout 预算,不改变识别输入和模型调用方式。测试计划
命令:
cargo test结果:本地 Rust 单测通过,
546 passed; 0 failed证据路径:本地终端运行结果
命令:fork 上的 GitHub Actions CI
结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670487
命令:fork 上的桌面安装包构建
Release Tauri (cross-platform)结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670561
命令:fork 上的 Android APK 构建
结果:通过
证据路径:https://github.com/Duyi-Wang/openless/actions/runs/28922670488
PR Type
Bug fix, Enhancement
Description
Split Foundry Local Whisper PCM into 30s chunks for long audio
Add dynamic timeout based on actual audio duration for both Foundry and Sherpa
Reuse existing Whisper chunk split/join logic to avoid text gaps
Apply dynamic timeout across dictation, QA, overlay QA, and re-transcribe paths
Diagram Walkthrough
flowchart LR A["Audio PCM"] --> B["buffer_duration_ms()"] B --> C{"duration > 30s?"} C -- Yes --> D["split_pcm_by_duration(30s)"] D --> E["Transcribe each chunk separately"] E --> F["join_transcript_chunks()"] F --> G["Final transcript"] C -- No --> H["Transcribe whole audio"] H --> G B --> I["Calculate timeout: max(30, ceil(audio_secs)+20)"] I --> J["Set transcribe timeout"] J --> E J --> HFile Walkthrough
foundry_provider.rs
Implement PCM chunking for Foundry Local Whisperopenless-all/app/src-tauri/src/asr/local/foundry_provider.rs
FOUNDRY_WHISPER_CHUNK_LIMIT_MSconstant (30s)buffer_duration_ms()method to report buffered PCM durationtranscribe()to split PCM into chunks and transcribe eachsherpa_provider.rs
Add buffer duration reporting for Sherpa provideropenless-all/app/src-tauri/src/asr/local/sherpa_provider.rs
buffer_duration_ms()method for both Offline and Online modescoordinator.rs
Implement dynamic transcribe timeout for local ASRopenless-all/app/src-tauri/src/coordinator.rs
foundry_audio_transcribe_timeout(audio_secs)andsherpa_audio_transcribe_timeout(audio_secs)ActiveAsr::FoundryLocalWhisperandSherpaOnnxLocalbranches touse dynamic timeout
whisper.rs
Make Whisper chunk utilities publicopenless-all/app/src-tauri/src/asr/whisper.rs
split_pcm_by_durationandjoin_transcript_chunkspub(crate)forreuse
dictation.rs
Apply dynamic timeout to dictation end sessionopenless-all/app/src-tauri/src/coordinator/dictation.rs
timeout from buffer_duration_ms
qa_session.rs
Apply dynamic timeout to QA and overlay dictation pathsopenless-all/app/src-tauri/src/coordinator/qa_session.rs
dynamic timeout